import { createRouter, createWebHashHistory } from "vue-router";

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      name: "home",
      redirect: "/main/child1",
    },
    {
      path: "/main",
      redirect: "/main/child1",
      component: () => import("@/views/Layout.vue"),
      children: [
        {
          path: "child1",
          component: () => import("@/views/Child1.vue"),
        },
        {
          path: "child2",
          component: () => import("@/views/Child2.vue"),
        },
      ],
    },
    // Target container with #container not existed while xxx loading!
    {
      path: "/:pathMatch(.*)*",
      name: "error",
      component: () => import("@/views/404.vue"),
    },
  ],
});

export default router;
